import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/widgets/divider/solid_divider.dart";
import "package:flutter/material.dart";


class ListItem extends StatelessWidget {
  final Map info;

  const ListItem({
    super.key,
    required this.info,
  });

  // 获取状态颜色
  Color _getStatusColor(String status) {
    return status == "在线" ? Colors.green : Colors.red;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.fromLTRB(12, 12, 16, 12),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8),
        boxShadow: const [ThemeVars.boxShadow],
        color: Colors.white,
      ),
      child: Column(
        children: [
          Row(
            children: [
              Container(
                alignment: Alignment.center,
                padding: const EdgeInsets.all(4),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4),
                  color: ThemeVars.colorPrimaryLight,
                ),
                child: const Text(
                  "门禁",
                  style: TextStyle(
                    color: ThemeVars.colorPrimary,
                    fontSize: 10,
                    height: 1,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ),
              const SizedBox(width: 8,),
              Text(
                info["faceLockName"],
                style: const TextStyle(
                  color: ThemeVars.colorText,
                  fontSize: 14,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ],
          ),
          const SolidDivider(padding: EdgeInsets.symmetric(vertical: 8),),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  const Text(
                    "状态：",
                    style: TextStyle(
                      fontSize: 14,
                    ),
                  ),
                  Text(
                    info["statusName"] ?? "未知",
                    style: TextStyle(
                      fontSize: 14,
                      color: _getStatusColor(info["statusName"] ?? ""),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }

}